using System;
using System.Data;

namespace Lottery.Data
{
	/// <summary>
	/// Summary description for DrawingManager.
	/// </summary>
	public class DrawingManager
	{
		public static int Insert(Drawing drawing)
		{
			return SQLHelper.ExecCommandSql(
				String.Format("exec AddDrawing {0}, '{1}', {2}, {3}, {4}, {5}, {6}, {7}", 
				drawing.Number, drawing.Date, drawing.combination[0], drawing.combination[1], drawing.combination[2],
				drawing.combination[3], drawing.combination[4], drawing.combination[5]));
		}
		public static int Update(Drawing drawing)
		{
			return SQLHelper.ExecCommandSql(
				String.Format("exec UpdateDrawing {0}, '{1}', {2}, {3}, {4}, {5}, {6}, {7}", 
				drawing.Number, drawing.Date, drawing.combination[0], drawing.combination[1], drawing.combination[2],
				drawing.combination[3], drawing.combination[4], drawing.combination[5]));
		}
		public static DataTable GetAllDrawings()
		{
			string Query = "select d.ID, d.Number, d.Date, c.first, c.second, c.third, c.fourth, c.fifth, c.sixth " 
				+ " from Drawing d, Combination c "
				+ " where c.ID = d.CombinationID ";
			return SQLHelper.FillDataSet(Query).Tables[0];		
		}

		public DrawingManager()
		{
			//
			// TODO: Add constructor logic here
			//
		}
	}
}
